<style lang="less">
</style>

<template>
    <div>
        <Button type="primary" @click="handelClick(1)" v-if="isSelected(1)">星期日</Button>
        <Button type="ghost" @click="handelClick(1)" v-else>星期日</Button>
        <Button type="primary" class="margin-left-10" @click="handelClick(2)" v-if="isSelected(2)">星期一</Button>
        <Button type="ghost" class="margin-left-10" @click="handelClick(2)" v-else>星期一</Button>
        <Button type="primary" class="margin-left-10" @click="handelClick(3)" v-if="isSelected(3)">星期二</Button>
        <Button type="ghost" class="margin-left-10" @click="handelClick(3)" v-else>星期二</Button>
        <Button type="primary" class="margin-left-10" @click="handelClick(4)" v-if="isSelected(4)">星期三</Button>
        <Button type="ghost" class="margin-left-10" @click="handelClick(4)" v-else>星期三</Button>
        <Button type="primary" class="margin-left-10" @click="handelClick(5)" v-if="isSelected(5)">星期四</Button>
        <Button type="ghost" class="margin-left-10" @click="handelClick(5)" v-else>星期四</Button>
        <Button type="primary" class="margin-left-10" @click="handelClick(6)" v-if="isSelected(6)">星期五</Button>
        <Button type="ghost" class="margin-left-10" @click="handelClick(6)" v-else>星期五</Button>
        <Button type="primary" class="margin-left-10" @click="handelClick(0)" v-if="isSelected(0)">星期六</Button>
        <Button type="ghost" class="margin-left-10" @click="handelClick(0)" v-else>星期六</Button>

        <!--<Button v-for="item in weekValue" :value="item.value" :key="item.value">{{ item.label-->
            <!--}}-->
        <!--</Button>-->
    </div>
</template>

<script>
    export default {
        name: 'GuardWeek',
        data() {
            return {
                jsonWeek : null
            };
        },
        props: {
            weekValue: String
        },
        created() {
            this.jsonWeek = JSON.parse(this.weekValue);
        },
        computed: {
        },
        methods: {
            isSelected: function (w) {
                if (this.jsonWeek[w] == 1) {
                    return true;
                } else {
                    return false;
                }
            },
            handelClick(w) {
                this.jsonWeek[w] = !this.jsonWeek[w];
            }
        }
    };
</script>
